import '../../scss/resources.scss'
import React from 'react'
import { commonApi } from '../../api/common'

export default React.createClass({
    getInitialState() {
        return { resources: [] }
    },
    componentDidMount() {
        var self = this
        var mapId = this.props.params.id
        commonApi.enterMap({
            mapId: mapId
        }, function (err, data) {
            self.setState({ resources: data.resources })
        })
    },
    onClick(resourceId){
         var self = this
         commonApi.collection({resourceId:resourceId}, function(err, data){
             
         })
    },
    render() {
        let self = this
        let propName = window.G.propName
        let resourcesNode
        resourcesNode = this.state.resources.map(function (item) {
            return <div key={item}><button onClick={self.onClick.bind(self, item)}>{propName[item]}</button></div>
        })
        return <div id='resources'>
            <div className='head'>
                <div className='title'>资源</div>
                <div className='desc'></div>
            </div>
            <div className=''>{resourcesNode}</div>
        </div>
    }
})
